import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LookupPlayerData } from "../LookupPlayerData";
import { AcupointData } from "./AcupointData";
import { Cache } from "../../../cache/Cache";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class AcupointRootPanel
    
    export  class AcupointRootPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            loc1.width = 172;
            loc1.height = 68;
            addChild(loc1);
            this._rootLevelTf = new GTextFormat(FontUtil.songtiName, 18, 16776960);
            this._rootIntroTf = new GTextFormat("", 12, 11661311, null, null, null, null, null, null, null, null, null, 2);
            this._rootLevelTxt = this.createTextfield(10, 5, 150, 25, "", this._rootLevelTf);
            this._rootIntroTxt = this.createTextfield(10, 25, 160, 45, "", this._rootIntroTf);
            this._rootIntroTxt.wordWrap = true;
            this._rootIntroTxt.multiline = true;
            this._rootUpgradeBtn = ObjCreate.createGButton(Language.getString(30104), 100, 45, 65, 20, this, "Button");
            this._rootUpgradeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onUpgradeBtnClickHandler);
            return;
        }

        /* internal  */createTextfield(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).selectable = false;
            loc1.mouseEnabled = false;
            loc1.x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.text = arg5;
            loc1.defaultTextFormat = arg6;
            addChild(loc1);
            return loc1;
        }

        /* internal  */onUpgradeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.AcupointOpenRootModule, this._step));
            return;
        }

        public updateRootLevel(arg1: int, arg2: Map<any, any> /* flash.utils.Dictionary */=null): void
        {
            var loc1=arg2[arg1];
            var loc2=100;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    loc2 = LookupPlayerData.getRootBreakThroughsLevelByStep(arg1);
                }
            }
            else 
            {
                loc2 = AcupointData.getRootBreakThroughsLevelByStep(arg1);
            }
            this._rootLevelTxt.htmlText = "<font size=\'18\' color=\'#ffff00\'>" + Language.getString(30105) + "  <font size=\'14\' color=\'#ffff00\'>" + Language.getString(30106) + loc1 + "/" + loc2 + "</font></font>";
            return;
        }

        public updateRootAttAdd(arg1: int, arg2: Map<any, any> /* flash.utils.Dictionary */=null): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=0;
            this._step = arg1;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    loc1 = LookupPlayerData.acupointInfo;
                    loc2 = LookupPlayerData.lookupData.miniPlayer.career;
                    loc3 = LookupPlayerData.lookupData.miniPlayer.careerEnable;
                }
            }
            else 
            {
                loc1 = AcupointData.acupointInfo;
                loc2 = Cache.instance.role.careerBasic;
                loc3 = Cache.instance.role.careerEnabled;
            }
            var loc4=AcupointData.getAttributesByStep(arg1, 1, loc1.attributes);
            var loc5=AcupointData.getAttributeStr(loc4, "", loc2, loc3, false, false);
            var loc6="<font color=\'#ffff00\'>(" + AcupointData.getAcupointName(arg1) + ")</font><font color=\'#b1efff\'>  " + Language.getStringByParam(30107, loc5) + " +" + arg2[arg1] + "%</font>";
            this._rootIntroTxt.htmlText = loc6;
            if (this._mode == GModuleEvent.Mode_Other) 
            {
                this._rootUpgradeBtn.enabled = false;
            }
            return;
        }

        /* internal */ /* var */_rootLevelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rootIntroTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rootLevelTf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rootIntroTf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rootUpgradeBtn: GButton;

        /* internal */ /* var */_step: int;

        /* internal */ /* var */_mode: string="自己";
    }
